<!DOCTYPE html>
<html>
    <head>
        <!-- 页面meta -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>传智健康</title>
        <meta name="description" content="传智健康">
        <meta name="keywords" content="传智健康">
        <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
        <!-- 引入样式 -->
        <link rel="stylesheet" href="../css/style.css">
        <script src="../plugins/echarts/echarts.js"></script>
        <link rel="stylesheet" href="../plugins/elementui/index(1).css">
        <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
        <!-- 引入组件库 -->
        <script type="text/javascript" src="../js/jquery.min.js"></script>
        <script src="../js/vue.js"></script>
        <script src="../plugins/elementui/index.js"></script>
        <script src="../js/axios-0.18.0.js"></script>
    </head>
    <style>
        .block {
            margin-left: 20px;
            margin-top: 10px;
        }
    </style>
    <body class="hold-transition">
        <div id="app">
            <div class="content-header">
                <h1>统计分析<small>会员数量</small></h1>
                <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
                    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item>统计分析</el-breadcrumb-item>
                    <el-breadcrumb-item>会员数量</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
                <div class="block">
                    <el-date-picker
                            v-model="queryDate"
                            type="daterange"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            format="yyyy 年 MM 月 dd 日"
                            value-format="yyyy-MM-dd"
                    >
                    </el-date-picker>
                    <el-button  @click="findOrder()">查询</el-button>
                </div>
            <div class="app-container">
                <div class="box">
                    <div id="chart12" style="height:600px; z-index: 999999">

                    </div>
                </div>
            </div>
        </div>
    </body>
    <script>
        $(document).ready(function() {
            Vue.prototype.$ajax = $.ajax;
           var common = new Vue({
                el: '#app',
                data: {
                    queryDate: [new Date(2019, 10, 10), new Date(2020, 10, 11)],
                    return:{
                        pickerOptions: {
                            shortcuts: [{
                                text: '最近一周',
                                onClick(picker) {
                                    const end = new Date();
                                    const start = new Date();
                                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                                    picker.$emit('pick', [start, end]);
                                }
                            }, {
                                text: '最近一个月',
                                onClick(picker) {
                                    const end = new Date();
                                    const start = new Date();
                                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                                    picker.$emit('pick', [start, end]);
                                }
                            }, {
                                text: '最近三个月',
                                onClick(picker) {
                                    const end = new Date();
                                    const start = new Date();
                                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                                    picker.$emit('pick', [start, end]);
                                }
                            }]
                        },
                    },

                    chart: null
                },
                mounted() {
                    this.chart = echarts.init(document.getElementById('chart12'));
                },
                created: function () {
                },
                methods: {
                    findOrder(){
                        axios.post("/order/findByDate.do?",this.queryDate).then((res)=> {
                            this.chart.setOption({
                                title: {
                                    text: '每日体检预约与到诊人数',
                                    left: 'center'
                                },
                                tooltip: {
                                    trigger: 'item',
                                    formatter: '{a} <br/>{b} : {c}'
                                },
                                legend: {
                                    left: 'left',
                                    data: ['每日预约数', '每日到诊数']
                                },
                                xAxis: {
                                    type: 'category',
                                    name: 'x',
                                    splitLine: {show: false},
                                    data: res.data.data.allDate
                                },
                                grid: {
                                    left: '3%',
                                    right: '4%',
                                    bottom: '3%',
                                    containLabel: true
                                },
                                yAxis: {
                                    type: 'log',
                                    name: 'y',
                                    minorTick: {
                                        show: true
                                    },
                                    minorSplitLine: {
                                        show: true
                                    }
                                },
                                series: [
                                    {
                                        name: '每日预约数',
                                        type: 'line',
                                        data: res.data.data.perOrder
                                    },
                                    {
                                        name: '每日到诊数',
                                        type: 'line',
                                        data: res.data.data.perCome
                                    }

                                ]
                            })
                        })
                    }
                }
            })

        })
    </script>
</html>
